<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tour.tld" prefix="t" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

	
	<t:header login="${sessionScope.login}"/>	

	<h3>Hotel manager </h3>
	<p>

	<jsp:scriptlet> if (request.getAttribute("message") != null) { </jsp:scriptlet>
	<jsp:expression> request.getAttribute("message") </jsp:expression>
	<jsp:scriptlet> request.setAttribute("message", null); } </jsp:scriptlet>
	
	<form action="controller" name="hotelCreation" method="post">
		Name 		<input type="text" name="name"> <p>
		Stars 		<input type="text" name="stars"> <p>
		Tv 			<input type="checkbox" name="tv" value="true" > <p>
		Conditioning<input type="checkbox" name="conditioning" value="true" > <p> 
		Feeding: 
		<p> <input type="radio" name="feeding" value="AI"> All Inclusive </p>
		<p> <input type="radio" name="feeding" value="BB"> Bed and Breakfast </p>
		<p> <input type="radio" name="feeding" value="HB"> Half Board </p>
 		<p> <input type="hidden" name="action" value="createHotel">
 		<p> <input type="submit" value="Create Hotel">
 		<p>
 		
	</form>
	
		<form action="controller">
		<input type = "hidden" name = "action" value = "loadAllHotels">
		<input type = "hidden" name = "pageNumber" value = "1">
		<input type = "hidden" name = "address" value = "HOTEL_MANAGER">
 		<input type = "submit" value = "Load All Hotels">
		
	</form> <p>
	
	<c:if test="${requestScope.entityList ne null}">
		
		<table>
		<tr>
			<th>ID</th>
			<th>Name</th>
			<th>Stars</th>
            <th>TV</th>
            <th>Conditioning</th>
            <th>Feeding</th>
		</tr>
	
		<c:forEach items="${requestScope.entityList}" var="entity">
			<t:hotel hotel="${entity}"/>
			<p>
		</c:forEach>
		</table>
	
		
		<table border="1" cellpadding="5" cellspacing="5">
        <tr>
            <c:forEach begin="1" end="${requestScope.numberOfPages}" var="i">
             <c:choose>
                    <c:when test="${requestScope.pageNumber eq i}">
                        <td>${i}</td>
                    </c:when>
                    <c:otherwise>
                        <td><a href="controller?action=loadAllHotels&pageNumber=${i}&address=HOTEL_MANAGER">${i}</a></td>
                    </c:otherwise>
                </c:choose>
            </c:forEach>
        </tr>
    	</table>
    	
	
	
	<c:if test="${requestScope.pageNumber ne 1}">
			<a href="controller?action=loadAllHotels&pageNumber=${requestScope.pageNumber-1}&address=HOTEL_MANAGER"> Previous </a>
	</c:if>
	
	<c:if test = "${requestScope.pageNumber lt requestScope.numberOfPages}">
    		<a href="controller?action=loadAllHotels&pageNumber=${requestScope.pageNumber+1}&address=HOTEL_MANAGER"> Next </a>
    </c:if>
	
	</c:if>
	
	
	
</body>
</html>